package xin.marcher.wind.process.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;
import xin.marcher.framework.mybatis.dao.BaseDAO;
import xin.marcher.wind.process.domain.entity.TradePlatformBizDO;
import xin.marcher.wind.process.mapper.TradePlatformBizMapper;

import java.util.List;

/**
 * <p>
 * 交易平台商家表 DAO
 * </p>
 *
 * 
 */
@Repository
public class TradePlatformBizDAO extends BaseDAO<TradePlatformBizMapper, TradePlatformBizDO> {

    public TradePlatformBizDO getOne(String bizId) {
        if(StringUtils.isEmpty(bizId)) {
            return null;
        }

        LambdaQueryWrapper<TradePlatformBizDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TradePlatformBizDO::getBizId,bizId);
        List<TradePlatformBizDO> list = list(queryWrapper);
        if(CollectionUtils.isNotEmpty(list)) {
            return list.get(0);
        }

        return null;
    }

    public List<TradePlatformBizDO> listByBizId(List<String> bizIds) {
        if(CollectionUtils.isEmpty(bizIds)) {
            return null;
        }

        LambdaQueryWrapper<TradePlatformBizDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(TradePlatformBizDO::getBizId,bizIds);

        return list(queryWrapper);
    }

    public Boolean deleteBiz(String bizId) {
        if(StringUtils.isEmpty(bizId)) {
            return false;
        }

        LambdaQueryWrapper<TradePlatformBizDO> queryWrapper = new LambdaQueryWrapper<>();
        return remove(queryWrapper.eq(TradePlatformBizDO::getBizId, bizId));
    }

}
